
import * as env from '../env.js'


export const post = (url,data,dataType,noNeedToken)=>{
 
	console.log('###ENV,',env);
	return new Promise((resolve,reject)=>{

		uni.request({
			header:{
				'content-type':dataType ? dataType : 'application/json'
			},
			noNeedToken:!noNeedToken,
			url: url.startsWith('http')?url:(env.default.baseUrl+url),
			data:data,
			method:'POST',
			success: (response) => {
				let data = response.data;
				resolve(data);
			},
            fail: (err)=>{
                reject(err);
            }
		});

	});
}


export const get = (url,data,dataType,noNeedToken)=>{
 
	return new Promise((resolve,reject)=>{

		uni.request({
			header:{
				'content-type':dataType ? dataType : 'application/json'
			},
			noNeedToken:!noNeedToken,
			url: url.startsWith('http')?url:(env.default.baseUrl+url),
			data:data,
			method:'GET',
			success: (response) => {
				let data = response.data;
				resolve(data);
			},
            fail: (err)=>{
                reject(err);
            }
		});

	});
};